package org.yangspring.samples.mvc.CtrlOracle;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.yangspring.samples.mvc.domainOracle.DBATables;
import org.yangspring.samples.mvc.serviceOracle.DBATablesService;

import java.util.List;

import static java.lang.System.out;

/**
 * Created by whyang on 2017/07/03.
 */


/*****
 * 本来配置文件 controller.xml里有默认页面的配置
 * 这里再配置一次映射，看效果应该是覆盖了controller.xml的配置
 * ****/

@Controller
//@RequestMapping("/")
public class OracleDefaultCtrl {

    private static final Logger logger = LoggerFactory.getLogger(OracleDefaultCtrl.class);

    @Autowired
//    @Resource(name = "dbaTablesService")
    private DBATablesService dbaTablesService;


//    @RequestMapping(value = "/")
    public String dbaTablesList(Model model){
        logger.warn("\nOracle SYS.DBA_TABLES Controller\n");

        model.addAttribute("table001", new DBATables());
        List<DBATables> dbatables = this.dbaTablesService.listDbaTables();
        logger.warn("\nDbatables007 Quantity:\t" + dbatables.size() + "\n");
        model.addAttribute("listDbaTables008", dbatables);
        return "listDbaTables";
    }

}
